package com.sky.mapper.user;

import com.sky.pojo.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

/**
 * @Description UserMapper
 * @Author lyh
 * @Date 2024-09-30
 */
@Mapper
public interface UserMapper {
    /**
     * 根据openid查询微信登录用户
     * @param openId
     * @return
     */
    @Select("select * from user where openid=#{openId}")
    User selectByOpenId(String openId);

    /**
     * 保存微信登录用户
     * @param user
     */
    void save(User user);
    @Select("select * from user where id=#{id}")
    User getById(Long id);
    @Delete("delete from user where id=#{id}")
    void deleteById(Long id);

    /**
     * 统计给的日期前的用户总量
     * @param begin
     * @return
     */
    Long selectCountBeforeDate(String begin);

    Map<String, Long> selectCountEveryDateUser(@Param("dateList") List<String> dateList, @Param("begin") String begin, @Param("end") String end);

    /**
     * 今天新增的用户数
     * @param begin
     * @param end
     * @return
     */
    Integer selectDayNewUser(String begin, String end);
}
